import cv2
import numpy as np
import matplotlib.pyplot as plt

def main():
    img = cv2.imread('6/test.jpg')

    if img is not None:
        plt.imshow(img)
        plt.show()

        img1_locate = np.float32([[565, 160],
                                  [1180, 170],
                                  [495, 810],
                                  [1310, 805]])
        
        img2_locate = np.float32([[50, 50],
                                  [500,50],
                                  [50, 500],
                                  [500, 500]])
        
        M = cv2.getPerspectiveTransform(img1_locate, img2_locate)

        img2 = cv2.warpPerspective(img, M, (500, 500))

        cv2.imshow('img', img)
        cv2.imshow('img2', img2)
        cv2.waitKey(0)
        cv2.destroyAllWindows()

    else:
        print('Image not found')

if __name__ == '__main__':
    main()